package br.com.adimoveis.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import br.com.adimoveis.model.AparenciaImovel;
import br.com.adimoveis.model.Bairro;
import br.com.adimoveis.model.Imovel;
import br.com.adimoveis.model.TipoImovel;

public class ImovelDaoImpl extends HibernateDaoSupport implements ImovelDao{

	
	public List<Imovel> getImoveis() {
		return getHibernateTemplate().find("from Imovel i");
	}

	public List<AparenciaImovel> getAparencias() {
		return getHibernateTemplate().find("from AparenciaImovel i order by i.nome");
	}

	public List<Bairro> getBairros() {
		return getHibernateTemplate().find("from Bairro i order by i.nome");
	}

	public List<TipoImovel> getTipos() {
		return getHibernateTemplate().find("from TipoImovel i order by i.nome");
	}

	public void save(Imovel imovel) {

		getHibernateTemplate().saveOrUpdate(imovel);
	}

	public void delete(Imovel imovel) {
		getHibernateTemplate().delete(imovel);
	}
}
